package com.xigua._数学;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: 给你一个整数n，请你返回所有0到1之间（不包括0和1）满足分母小于等于 n的最简分数.分数可以以任意顺序返回。
 * @date 2022/2/109:33
 */
public class _1447_最简分数 {

    public static void main(String[] args) {
        List<String> strings = simplifiedFractions(6);
        for (int i = 0; i < strings.size(); i++) {
            System.out.print(strings.get(i)+" ");
        }
    }

    public static List<String> simplifiedFractions(int n) {
        List<String> list = new ArrayList<>();
        for (int i = 1; i < n; i++) {
            for (int j = i+1; j <= n; j++) {
                if (gys(i,j)==1){
                    list.add(i+"/"+j);
                }
            }
        }
        return list;
    }

    public static int gys(int a,int b){
        return  b == 0 ? a : gys(b,a%b);
    }




}
